GINO Graphics Suite - GINO v9.0  

Circular Arcs

The routines for drawing circular arcs are:

gDrawArcTo2D(xc, yc, xe, ye, sense)
gDrawArcBy2D(dxc, dyc, dxe, dye, sense)

All arcs are drawn from the start pen position. The radius of an arc is the distance from the start point to the centre. The end pen position or any point on the straight line from the centre through the end point of the arc may be specified. The end pen position will then be calculated.

Two-Dimensional Arcs

Specifying the start pen position, end pen position and centre enables two possible arcs to be drawn - the start and end points can be joined by either a clockwise or an anticlockwise movement. The direction is indicated by sense.

Clockwise/Anticlockwise

If the value of sense is GCLOCKWISE, then a clockwise arc is drawn, and if it is GANTICLOCKWISE, an anticlockwise arc is drawn.

Examples:

Minor Chord

[C/C++]
gMoveTo2D(70.0,60.0);
gDrawArcTo2D(100.0,100.0,50.0,100.0,GCLOCKWISE);
[F90]
call gMoveTo2D(70.0,60.0)
call gDrawArcTo2D(100.0,100.0,50.0,100.0,GCLOCKWISE)
call gDrawArcBy2D(r,0.0,r+r,0.0,GCLOCKWISE)

Semicircular Arc

Drawing Circles

Circles can be drawn using the arc routines by specifying the end point of the arc as being the start pen position. The value of sense is immaterial.

Examples:

[C/C++]
gMoveTo2D(100.0,0.0);
gDrawArcTo2D(100.0,50.0,100.0,0.0,GANTICLOCKWISE);
[F90]
call gMoveTo2D(100.0,0.0)
call gDrawArcTo2D(100.0,50.0,100.0,0.0,GANTICLOCKWISE)

Circular Arc

[C/C++]
/* Move to base of circle */
   gMoveTo2D(x,y-r);
/* Draw circle */
   gDrawArcBy2D(0.0,r,0.0,0.0,GANTICLOCKWISE);
[F90]
! Move to base of circle
   call gMoveTo2D(x,y-r)
! Draw circle
   call gDrawArcBy2D(0.0,r,0.0,0.0,GANTICLOCKWISE)

Drawing Ellipses

Two dimensional ellipses may be drawn using the following routine:

gDrawEllipse2D(xc, yc, angle, major, minor)

where xc, yc is the centre of the ellipse and angle is the rotation of the major axis from the X axis in the current transformation. The arguments major and minor are the two radii of the ellipse.

Hardware and Software Arcs

When using devices capable of drawing hardware arcs, software arcs may be selected by using the routine:

gSetArcMode(swi)

The argument switches hardware arcs on (swi = GHARD) and off (swi = GSOFT). Hardware arcs can be windowed and transformed and are subject to the current line mode, but remain unaffected by the control routines gSetArcIncrement() and gSetArcTolerance().

Software arcs should be selected for these routines to have effect.

Arc Control Routines

GINO arcs are drawn as a series of straight line chords. Enough chords are drawn to produce relatively smooth arcs. The number of line segments per arc can be controlled using one of the routines:

gSetArcIncrement(n)
gSetArcTolerance(tol)

Controlling the Number of Chords

The argument to routine gSetArcIncrement() specifies the number of straight line segments (or chords) per full circle for all subsequent ARC routines.

Examples:

call gSetArcIncrement(8)

In this case, for example, subsequent semicircles would consist of four chords.

[C/C++]
gMoveTo2D(x-r, y);
gSetArcIncrement(6);
gDrawArcBy2D(r,0.0,0.0,0.0,GANTICLOCKWISE);
[F90]
call gMoveTo2D(x-r, y)
call gSetArcIncrement(6)
call gDrawArcBy2D(r,0.0,0.0,0.0,GANTICLOCKWISE)

Arc Increments

Note that calling gSetArcIncrement() will disable hardware generated arcs.

Controlling Tolerance

The tolerance is the maximum distance allowed between the approximating chord and the true arc.

Arc Tolerance

The default distance is dependent on the output device. This can be changed by the use of gSetArcTolerance() to produce rougher or smoother arcs. The smoothness of the arc is ultimately dependent on the accuracy of the device. For example, to alter the tolerance to produce rough arcs, (i.e. set tolerance to 1mm) use:

call gSetArcTolerance(1.0)

Notes:

(a) The default settings of tolerance and number of chords can be reset by calling gSetArcTolerance() or gSetArcIncrement() with zero arguments.

(b) The end position will always be on the circumference of the true arc.

(c) The most recently called of gSetArcTolerance() and gSetArcIncrement() dictates the appearance of the chords.

(d) If the user specifies a finer tolerance than is permitted by the resolution of the device, then gSetArcTolerance() reverts to half the minimum step size, that is to say the smoothest arc possible on that device.

Arc Settings

The current settings of the arc control parameters may be obtained using the routine:

gEnqArcState(swi, nincs, tol)

This returns the state of the hardware/software switch, the number of chords per full circle, and the tolerance. nincs is returned zero if gSetArcTolerance() was called more recently than gSetArcIncrement().

Use of Arc Routines

To draw an object a number of times, use a routine. By the use of routine arguments, the position, size and orientation of the object may be varied either locally from within the routine, or from the calling program.

For example, to draw a dumb-bell at position (100.0,100.0) width = 100.0, radius = 10.0, and length = 50.0:

call dumb(100.,100.,10.,10.,50.)

To draw a dumb-bell at position (100.0,130.0) of half the size:

call dumb(100.,130.,5.,5.,25.)

The following routine would draw the dumb-bell shown below:

[C/C++]
void dumb(float xc, float yc, float width, float radius,
          float length)
{
/* Move to absolute origin of object */
   gMoveTo2D(xc, yc);
/* Move to start of drawing */
   gMoveBy2D(-length/2.0,width/2.0);
/* Left-hand end */
   gDrawArcBy2D(-radius,-width/2.0,0.0,-width,GANTICLOCKWISE);
/* Bottom horizontal */
   gDrawLineBy2D(length,0.0);
/* Right-hand end */
   gDrawArcBy2D(radius,width/2.0,0.0,width,GANTICLOCKWISE);
/* Top horizontal */
   gDrawLineBy2D(-length,0.0);
}
[F90]
subroutine dumb(xc, yc, width, radius, length)
use gino_f90
real xc, yc, width, radius, length
! Move to absolute origin of object
   call gMoveTo2D(xc, yc)
! Move to start of drawing
   call gMoveBy2D(-length/2.0,width/2.0)
! Left-hand end
   call gDrawArcBy2D(-radius,-width/2.0,0.0,-width,GANTICLOCKWISE)
! Bottom horizontal
   call gDrawLineBy2D(length,0.0)
! Right-hand end
   call gDrawArcBy2D(radius,width/2.0,0.0,width,GANTICLOCKWISE)
! Top horizontal
   call gDrawLineBy2D(-length,0.0)
   return

Note the use of relative moves and lines within the routine.